package m202405.d09;

import java.util.HashMap;

/**
 * @@author: 爱做梦的锤子
 * @date: 2024/5/9 18:35
 */
public class Q1 {
    public int[] twoSum(int[] nums, int target) {
        int[] rs = new int[2];
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            map.put(nums[i], i);
        }
        for (int i = 0; i < nums.length; i++) {
            Integer index = map.get(target - nums[i]);
            if (index == null || index == i) {
                continue;
            }
            rs[0] = i;
            rs[1] = index;
            return rs;
        }
        return rs;
    }
}
